/**
 * 宝牌
 */
class GameSceneBao extends egret.DisplayObjectContainer {

    bg: egret.Bitmap;
    baoText: egret.Bitmap;

    cardView: CardView;

    constructor() {
        super();
        this.initView();
    }

    initView() {

        this.bg = new egret.Bitmap(RES.getRes("game_bao_bg"));
        this.bg.anchorOffsetX = this.bg.width >> 1;
        this.bg.anchorOffsetY = this.bg.height >> 1;
        this.addChild(this.bg);

        this.baoText = new egret.Bitmap(RES.getRes("game_baopai"));
        this.baoText.anchorOffsetX = this.baoText.width >> 1;
        this.baoText.anchorOffsetY = this.baoText.height >> 1;
        this.baoText.y = 35;
        this.addChild(this.baoText);

        this.cardView = CardView.create(1, 3, null);
        this.cardView.posView(0, -12);
        this.addChild(this.cardView);

        if (GameConfig.gameType == GameType.bayan) {
            this.baoText.visible = false;
        }
    }

    set bao(bao: any) {
        switch (bao) {
            case "no":
                this.no();
                break;
            case "anbao":
                this.anbao();
                break;
            default:
                this.mingbao(bao);
                break;
        }
        this.cardView.scaleX = this.cardView.scaleY = .75;
    }

    private no() {
        this.cardView.changeStyle(2);
        this.cardView.posView(-1, -14);
    }

    private anbao() {
        this.cardView.changeStyle(3);
        this.cardView.icon.texture = RES.getRes("anbao");
        this.cardView.posView(0, -12);
    }

    private mingbao(pai: any) {
        this.cardView.changeStyle(3);
        this.cardView.changePai(pai);
        this.cardView.posView(0, -12);
    }
}